package com.wx.wxsecondskill.service;

import com.wx.commons.utils.IdUtils;
import com.wx.wxsecondskill.dao.UserDao;
import com.wx.wxsecondskill.po.User;
import com.wx.wxsecondskill.utils.ChineseName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName UserService
 * @Author wx
 * @Description 用户业务层
 * @Date 2018-11-14-22:05
 */
@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    public User getById(String id) {
        return userDao.getById(id);
    }

    @Transactional
    public boolean tx() {
        for (int i = 0; i<=50000; i++) {
            User u1 = new User();
            u1.setId(IdUtils.getId());
            u1.setName(ChineseName.generateChineseName());
            userDao.insert(u1);
        }
        return true;
    }

    /**
     * @methodName: getFirstUser
     * @author: wx
     * @description: 获取第一个用户
     * @param
     * @date: 2018/11/17
     * @return: com.wx.wxsecondskill.po.User
     */
    public User getFirstUser(){
        return userDao.getFirstUser();
    }
}
